home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / gnu_st.lha / gnu_st / smalltalk-1.1.1 / texinfo.tex < prev    next >
Text File  |  1991-09-12  |  79KB  |  2,508 lines

  1. %% TeX macros to handle texinfo files
  2.  
  3. %   Copyright (C) 1985, 1986, 1988, 1990 Free Software Foundation, Inc.
  4.  
  5. %This texinfo.tex file is free software; you can redistribute it and/or
  6. %modify it under the terms of the GNU General Public License as
  7. %published by the Free Software Foundation; either version 1, or (at
  8. %your option) any later version.
  9.  
  10. %This texinfo.tex file is distributed in the hope that it will be
  11. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  12. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. %General Public License for more details.
  14.  
  15. %You should have received a copy of the GNU General Public License
  16. %along with this texinfo.tex file; see the file COPYING.  If not, write
  17. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  18. %USA.
  19.  
  20.  
  21. %In other words, you are welcome to use, share and improve this program.
  22. %You are forbidden to forbid anyone else to use, share and improve
  23. %what you give them.   Help stamp out software-hoarding!
  24.  
  25. \def\texinfoversion{2.13}
  26. \message{Loading texinfo package [Version \texinfoversion]:}
  27. \message{}
  28.  
  29. % Print the version number if in a .fmt file.
  30. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  31.  
  32. % Save some parts of plain tex whose names we will redefine.
  33.  
  34. \let\ptexlbrace=\{
  35. \let\ptexrbrace=\}
  36. \let\ptexdot=\.
  37. \let\ptexstar=\*
  38. \let\ptexend=\end
  39. \let\ptexbullet=\bullet
  40. \let\ptexb=\b
  41. \let\ptexc=\c
  42. \let\ptexi=\i
  43. \let\ptext=\t
  44. \let\ptexl=\l
  45. \let\ptexL=\L
  46.  
  47. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  48.  
  49. \message{Basics,}
  50. \chardef\other=12
  51.  
  52. \hyphenation{ap-pen-dix}
  53. \hyphenation{mini-buf-fer mini-buf-fers}
  54. \hyphenation{eshell}
  55.  
  56. % Margin to add to right of even pages, to left of odd pages.
  57. \newdimen \bindingoffset  \bindingoffset=0pt
  58. \newdimen \normaloffset   \normaloffset=\hoffset
  59. \newdimen\pagewidth \newdimen\pageheight
  60. \pagewidth=\hsize \pageheight=\vsize
  61.  
  62. %---------------------Begin change-----------------------
  63. %
  64. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  65. %
  66. \newdimen\cornerlong \newdimen\cornerthick
  67. \newdimen \topandbottommargin
  68. \newdimen \outerhsize \newdimen \outervsize
  69. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  70. \outerhsize=7in
  71. \outervsize=9.5in
  72. \topandbottommargin=.75in
  73. %
  74. %---------------------End change-----------------------
  75.  
  76. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  77. % does insertions itself, but you have to call it yourself.
  78. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  79. \def\onepageout#1{\hoffset=\normaloffset
  80. \ifodd\pageno  \advance\hoffset by \bindingoffset
  81. \else \advance\hoffset by -\bindingoffset\fi
  82. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  83. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  84. {\let\hsize=\pagewidth \makefootline}}}%
  85. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  86.  
  87.  
  88. % Here is a modification of the main output routine for Near East Publications
  89. % This provides right-angle cropmarks at all four corners.
  90. % The contents of the page are centerlined into the cropmarks,
  91. % and any desired binding offset is added as an \hskip on either
  92. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  93. %
  94. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  95.          \shipout
  96.          \vbox to \outervsize{\hsize=\outerhsize
  97.                  \vbox{\line{\ewtop\hfill\ewtop}}
  98.                  \nointerlineskip
  99.                  \line{\vbox{\moveleft\cornerthick\nstop}
  100.                        \hfill
  101.                        \vbox{\moveright\cornerthick\nstop}}
  102.                  \vskip \topandbottommargin
  103.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  104.             \vbox{
  105.             {\let\hsize=\pagewidth \makeheadline}
  106.             \pagebody{#1}
  107.             {\let\hsize=\pagewidth \makefootline}}
  108.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  109.          \vskip \topandbottommargin plus1fill minus1fill
  110.                  \boxmaxdepth\cornerthick
  111.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  112.                        \hfill
  113.                        \vbox{\moveright\cornerthick\nsbot}}
  114.                  \nointerlineskip
  115.                  \vbox{\line{\ewbot\hfill\ewbot}}
  116.     }
  117.   \advancepageno 
  118.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  119. %
  120. % Do @cropmarks to get crop marks
  121. \def\cropmarks{\let\onepageout=\croppageout }
  122.  
  123. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  124. {\catcode`\@ =11
  125. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  126. \dimen@=\dp#1 \unvbox#1
  127. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  128. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  129. }
  130.  
  131. %
  132. % Here are the rules for the cropmarks.  Note that they are
  133. % offset so that the space between them is truly \outerhsize or \outervsize
  134. % (P. A. MacKay, 12 November, 1986)
  135. %
  136. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  137. \def\nstop{\vbox
  138.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  139. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  140. \def\nsbot{\vbox
  141.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  142.  
  143. % Parse an argument, then pass it to #1.
  144. % The argument can be delimited with [...] or with "..." or braces
  145. % or it can be a whole line.
  146. % #1 should be a macro which expects
  147. % an ordinary undelimited TeX argument.
  148.  
  149. \def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
  150.  
  151. \def\parseargx{%
  152. \ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
  153. \aftergroup \parseargline %
  154. \fi \endgroup}
  155.  
  156. {\obeyspaces %
  157. \gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
  158.  
  159. \gdef\obeyedspace{\ }
  160.  
  161. \def\parseargline{\begingroup \obeylines \parsearglinex}
  162. {\obeylines %
  163. \gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
  164.  
  165. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  166.  
  167. %% These are used to keep @begin/@end levels from running away
  168. %% Call \inENV within environments (after a \begingroup)
  169. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  170. \def\ENVcheck{%
  171. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  172. \endgroup\fi} % This is not perfect, but it should reduce lossage
  173.  
  174. % @begin foo  is the same as @foo, for now.
  175. \newhelp\EMsimple{Type <Return> to continue}
  176.  
  177. \outer\def\begin{\parsearg\beginxxx}
  178.  
  179. \def\beginxxx #1{%
  180. \expandafter\ifx\csname #1\endcsname\relax
  181. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  182. \csname #1\endcsname\fi}
  183.  
  184. %% @end foo executes the definition of \Efoo.
  185. %% foo can be delimited by doublequotes or brackets.
  186.  
  187. \def\end{\parsearg\endxxx}
  188.  
  189. \def\endxxx #1{%
  190. \expandafter\ifx\csname E#1\endcsname\relax
  191. \expandafter\ifx\csname #1\endcsname\relax
  192. \errmessage{Undefined command @end #1}\else
  193. \errorE{#1}\fi\fi
  194. \csname E#1\endcsname}
  195. \def\errorE#1{
  196. {\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
  197.  
  198. % Single-spacing is done by various environments.
  199.  
  200. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  201. \def\singlespace{%
  202. {\advance \baselineskip by -\singlespaceskip
  203. \kern \baselineskip}%
  204. \baselineskip=\singlespaceskip
  205. }
  206.  
  207. %% Simple single-character @ commands
  208.  
  209. % @@ prints an @
  210. % Kludge this until the fonts are right (grr).
  211. \def\@{{\tt \char '100}}
  212.  
  213. % Define @` and @' to be the same as ` and '
  214. % but suppressing ligatures.
  215. \def\`{{`}}
  216. \def\'{{'}}
  217.  
  218. % Used to generate quoted braces.
  219.  
  220. \def\mylbrace {{\tt \char '173}}
  221. \def\myrbrace {{\tt \char '175}}
  222. \let\{=\mylbrace
  223. \let\}=\myrbrace
  224.  
  225. % @: forces normal size whitespace following.
  226. \def\:{\spacefactor=1000 }
  227.  
  228. % @* forces a line break.
  229. \def\*{\hfil\break}
  230.  
  231. % @. is an end-of-sentence period.
  232. \def\.{.\spacefactor=3000 }
  233.  
  234. % @w prevents a word break
  235. \def\w #1{\hbox{#1}}
  236.  
  237. % @group ... @end group  forces ... to be all on one page.
  238.  
  239. \def\group{\begingroup% \inENV ???
  240. \def \Egroup{\egroup\endgroup}
  241. \vbox\bgroup}
  242.  
  243. % @need space-in-mils
  244. % forces a page break if there is not space-in-mils remaining.
  245.  
  246. \newdimen\mil  \mil=0.001in
  247.  
  248. \def\need{\parsearg\needx}
  249.  
  250. \def\needx #1{\par %
  251. \begingroup %
  252. \dimen0=\pagetotal %
  253. \advance \dimen0 by #1\mil %
  254. \ifdim \dimen0>\pagegoal \vfill\eject \fi %
  255. \endgroup}
  256.  
  257.  
  258. % @br   forces paragraph break
  259.  
  260. \let\br = \par
  261.  
  262. % @dots{}  output some dots
  263.  
  264. \def\dots{$\ldots$}
  265.  
  266. % @page    forces the start of a new page
  267.  
  268. \def\page{\par\vfill\supereject}
  269.  
  270. % @exdent text....
  271. % outputs text on separate line in roman font, starting at standard page margin
  272.  
  273. \def\exdent{\errmessage{@exdent in filled text}}
  274.   % @lisp, etc, define \exdent locally from \internalexdent
  275.  
  276. {\obeyspaces
  277. \gdef\internalexdent{\parsearg\exdentzzz}}
  278.  
  279. \def\exdentzzz #1{{\advance \leftskip by -\lispnarrowing
  280. \advance \hsize by -\leftskip
  281. \advance \hsize by -\rightskip
  282. \leftline{{\rm#1}}}}
  283.  
  284. % @include file    insert text of that file as input.
  285.  
  286. \def\include{\parsearg\includezzz}
  287. \def\includezzz #1{{\def\thisfile{#1}\input #1
  288. }}
  289.  
  290. \def\thisfile{}
  291.  
  292. % @center line   outputs that line, centered
  293.  
  294. \def\center{\parsearg\centerzzz}
  295. \def\centerzzz #1{{\advance\hsize by -\leftskip
  296. \advance\hsize by -\rightskip
  297. \centerline{#1}}}
  298.  
  299. % @sp n   outputs n lines of vertical space
  300.  
  301. \def\sp{\parsearg\spxxx}
  302. \def\spxxx #1{\par \vskip #1\baselineskip}
  303.  
  304. % @comment ...line which is ignored...
  305. % @c is the same as @comment
  306. % @ignore ... @end ignore  is another way to write a comment
  307.  
  308. \def\comment{\parsearg \commentxxx}
  309.  
  310. \def\commentxxx #1{}
  311.  
  312. \let\c=\comment
  313.  
  314. % Prevent errors for section commands.
  315. % Used in @ignore and in failing conditionals.
  316. \def\ignoresections{%
  317. \let\chapter=\relax
  318. \let\unnumbered=\relax
  319. \let\unnumberedsec=\relax
  320. \let\unnumberedsection=\relax
  321. \let\unnumberedsubsec=\relax
  322. \let\unnumberedsubsection=\relax
  323. \let\unnumberedsubsubsec=\relax
  324. \let\unnumberedsubsubsection=\relax
  325. \let\section=\relax
  326. \let\subsec=\relax
  327. \let\subsubsec=\relax
  328. \let\subsection=\relax
  329. \let\subsubsection=\relax
  330. \let\appendix=\relax
  331. \let\appendixsec=\relax
  332. \let\appendixsection=\relax
  333. \let\appendixsubsec=\relax
  334. \let\appendixsubsection=\relax
  335. \let\appendixsubsubsec=\relax
  336. \let\appendixsubsubsection=\relax
  337. }
  338.  
  339. \def\ignore{\begingroup\ignoresections\ignorexxx}
  340. \long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces}
  341.  
  342. % Conditionals to test whether a flag is set.
  343.  
  344. \outer\def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
  345.  
  346. \def\ifsetxxx #1{\endgroup
  347. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail
  348. \else \let\temp=\relax \fi
  349. \temp}
  350. \def\Eifset{}
  351. \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
  352. \long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces}
  353.  
  354. \outer\def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
  355.  
  356. \def\ifclearxxx #1{\endgroup
  357. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax
  358. \else \let\temp=\ifclearfail \fi
  359. \temp}
  360. \def\Eifclear{}
  361. \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
  362. \long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces}
  363.  
  364. % Some texinfo constructs that are trivial in tex
  365.  
  366. \def\iftex{}
  367. \def\Eiftex{}
  368. \def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
  369. \long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces}
  370.  
  371. \long\def\menu #1\end menu{}
  372. \def\asis#1{#1}
  373.  
  374. \def\node{\ENVcheck\parsearg\nodezzz}
  375. \def\nodezzz#1{\nodexxx [#1,]}
  376. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  377. \let\lastnode=\relax
  378.  
  379. \def\donoderef{\ifx\lastnode\relax\else
  380. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  381. \let\lastnode=\relax}
  382.  
  383. \def\unnumbnoderef{\ifx\lastnode\relax\else
  384. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  385. \let\lastnode=\relax}
  386.  
  387. \def\appendixnoderef{\ifx\lastnode\relax\else
  388. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  389. \let\lastnode=\relax}
  390.  
  391. \let\refill=\relax
  392.   
  393. % @setfilename is done at the beginning of every texinfo file.
  394. % So open here the files we need to have open while reading the input.
  395. % This makes it possible to make a .fmt file for texinfo.
  396. \def\setfilename{%
  397.    \readauxfile
  398.    \opencontents
  399.    \openindices
  400.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  401.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  402.    \comment % Ignore the actual filename.
  403. }
  404.  
  405. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  406.  
  407. \def\inforef #1{\inforefzzz #1,,,,**}
  408. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, node `\losespace#1{}'}
  409. \def\losespace #1{#1}
  410.  
  411. \message{fonts,}
  412.  
  413. % Font-change commands.
  414.  
  415. %% Try out Computer Modern fonts at \magstephalf
  416. \font\tenrm=cmr10 scaled \magstephalf
  417. \font\tentt=cmtt10 scaled \magstephalf
  418. % Instead of cmb10, you many want to use cmbx10.
  419. % cmbx10 is a prettier font on its own, but cmb10
  420. % looks better when embedded in a line with cmr10.
  421. \font\tenbf=cmb10 scaled \magstephalf 
  422. \font\tenit=cmti10 scaled \magstephalf
  423. \font\tensl=cmsl10 scaled \magstephalf
  424. \font\tensf=cmss10 scaled \magstephalf
  425. \def\li{\sf}
  426. \font\tensc=cmcsc10 scaled \magstephalf
  427.  
  428. % Fonts for @defun, etc.
  429. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  430. \font\deftt=cmtt10 scaled \magstep1
  431. \def\df{\let\tt=\deftt \defbf}
  432.  
  433. % Font for title
  434. % There seems to have been a confusion: two definitions of this font.
  435. % It is not clear why, or which one is better.
  436. \font\titlerm = cmbx10 scaled \magstep5
  437. % this is too small -- rms, May 1990.
  438. %\font\titlerm = cmbx12 scaled \magstep2
  439.  
  440. % Fonts for indices and small examples.
  441. % We actually use the slanted font rather than the italic, 
  442. % because texinfo normally uses the slanted fonts for that.
  443. \font\ninett=cmtt9
  444. \font\indit=cmsl9 \font\indrm=cmr9
  445. \let\indtt=\ninett
  446. \def\indbf{\indrm} \def\indsl{\indit}
  447. \def\indexfonts{\let\it=\indit \let\sl=\indsl \let\bf=\indbf \let\rm=\indrm
  448. \let\tt=\indtt}
  449.  
  450. % Fonts for headings
  451. \font\chaprm=cmbx10 scaled \magstep3
  452. \font\chapit=cmti10 scaled \magstep3
  453. \font\chapsl=cmsl10 scaled \magstep3
  454. \font\chaptt=cmtt10 scaled \magstep3
  455. \font\chapsf=cmss10 scaled \magstep3
  456. \let\chapbf=\chaprm
  457.  
  458. \font\secrm=cmbx10 scaled \magstep2
  459. \font\secit=cmti10 scaled \magstep2
  460. \font\secsl=cmsl10 scaled \magstep2
  461. \font\sectt=cmtt10 scaled \magstep2
  462. \font\secsf=cmss10 scaled \magstep2
  463. \let\secbf=\secrm
  464.  
  465. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an fontlooked bad.
  466. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  467. % \font\ssecsl=cmsl10 scaled \magstep1
  468. % \font\ssectt=cmtt10 scaled \magstep1
  469. % \font\ssecsf=cmss10 scaled \magstep1
  470.  
  471. \font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  472. \font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  473. \font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  474. \font\ssectt=cmtt10 scaled 1315
  475. \font\ssecsf=cmss10 scaled 1315
  476.  
  477. \let\ssecbf=\ssecrm
  478.  
  479. \def\textfonts{\let\rm=\tenrm\let\it=\tenit\let\sl=\tensl\let\bf=\tenbf%
  480. \let\smallcaps=\tensc\let\sf=\tensf}
  481. \def\chapfonts{\let\rm=\chaprm\let\it=\chapit\let\sl=\chapsl\let\bf=\chapbf\let\tt=\chaptt\let\sf=\chapsf}
  482. \def\secfonts{\let\rm=\secrm\let\it=\secit\let\sl=\secsl\let\bf=\secbf\let\tt=\sectt\let\sf=\secsf}
  483. \def\subsecfonts{\let\rm=\ssecrm\let\it=\ssecit\let\sl=\ssecsl\let\bf=\ssecbf\let\tt=\ssectt\let\sf=\ssecsf}
  484. % Count depth in font-changes, for error checks
  485. \newcount\fontdepth \fontdepth=0
  486.  
  487. % Font for table of contents.
  488. \font\truesecrm=cmr12
  489.  
  490. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  491. %% serif) and @ii for TeX italic
  492.  
  493. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  494. % unless the following character is such as not to need one.
  495. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  496. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  497.  
  498. \let\i=\smartitalic
  499. \let\var=\smartitalic
  500. \let\dfn=\smartitalic
  501. \let\emph=\smartitalic
  502. \let\cite=\smartitalic
  503.  
  504. \def\b#1{{\bf #1}}
  505. \let\strong=\b
  506.  
  507. \def\t#1{{\tt \rawbackslash \frenchspacing #1}\null}
  508. \let\ttfont = \t
  509. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  510. \def\samp #1{`\tclose{#1}'\null}
  511. \def\key #1{{\tt \uppercase{#1}}\null}
  512. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  513.  
  514. \let\file=\samp
  515.  
  516. % @code is a modification of @t,
  517. % which makes spaces the same size as normal in the surrounding text.
  518. \newdimen\tclosesave
  519. \newdimen\tcloserm
  520. \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
  521. \fontdimen2\font=\tcloserm
  522. \def\ {{\fontdimen2\font=\tclosesave{} }}%
  523.  \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
  524. \let\code=\tclose
  525. %\let\exp=\tclose  %Was temporary
  526.  
  527. % @kbd is like @code, except that if the argument is just one @key command, 
  528. % then @kbd has no effect.
  529.  
  530. \def\xkey{\key}
  531. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  532. \ifx\one\xkey\ifx\threex\three \key{#2}%
  533. \else\tclose{\look}\fi
  534. \else\tclose{\look}\fi}
  535.  
  536. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  537.  
  538. \def\l#1{{\li #1}\null}        % 
  539.  
  540. \def\r#1{{\rm #1}}        % roman font
  541. \def\sc#1{{\smallcaps #1}}    % smallcaps font
  542. \def\ii#1{{\it #1}}        % italic font
  543.  
  544. \message{page headings,}
  545.  
  546. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  547. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  548.  
  549. % First the title page.  Must do @settitle before @titlepage.
  550. \def\titlefont#1{{\titlerm #1}}
  551.  
  552. \newtoks\realeverypar
  553. \newif\ifseenauthor
  554. \newif\iffinishedtitlepage
  555.  
  556. \def\titlepage{\begingroup \parindent=0pt \textfonts
  557.    \let\subtitlerm=\tenrm
  558.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  559.    %
  560.    \font\authorrm = cmbx12 scaled \magstep1
  561.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  562.    %
  563.    % Leave some space at the very top of the page.
  564.    \vglue\titlepagetopglue
  565.    %
  566.    % Now you can print the title using @title.
  567.    \def\title{\parsearg\titlezzz}%
  568.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  569.             % print a rule at the page bottom also.
  570.             \finishedtitlepagefalse
  571.             \vskip4pt \hrule height 4pt \vskip4pt}%
  572.    % No rule at page bottom unless we print one at the top with @title.
  573.    \finishedtitlepagetrue
  574.    %
  575.    % Now you can put text using @subtitle.
  576.    \def\subtitle{\parsearg\subtitlezzz}%
  577.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  578.    %
  579.    % @author should come last, but may come many times.
  580.    \def\author{\parsearg\authorzzz}%
  581.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  582.       {\authorfont \leftline{##1}}}%
  583.    %  
  584.    % Most title ``pages'' are actually two pages long, with space
  585.    % at the top of the second.  We don't want the ragged left on the second.
  586.    \let\oldpage = \page
  587.    \def\page{%
  588.       \finishtitlepage
  589.       \oldpage
  590.       \let\page = \oldpage
  591.       \hbox{}}%
  592. %   \def\page{\oldpage \hbox{}}
  593. }
  594.  
  595. \def\Etitlepage{%
  596.    \iffinishedtitlepage\else
  597.       \finishtitlepage
  598.    \fi
  599.    \endgroup\page\HEADINGSon
  600. }
  601.  
  602. \def\finishtitlepage{%
  603.    \vskip4pt \hrule height 2pt
  604.    \vskip\titlepagebottomglue
  605.    \finishedtitlepagetrue
  606. }
  607.  
  608. % @abstract PROGNAME
  609. % CONTENTS
  610. % @end abstract
  611.  
  612. \def\abstract{\parsearg\abstractxxx}
  613. \def\abstractxxx #1{}
  614. \def\Eabstract{}
  615.  
  616. %%% Set up page headings and footings.
  617.  
  618. \let\thispage=\folio
  619.  
  620. \newtoks \evenheadline    % Token sequence for heading line of even pages
  621. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  622. \newtoks \evenfootline    % Token sequence for footing line of even pages
  623. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  624.  
  625. % Now make Tex use those variables
  626. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}}
  627. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}}
  628.  
  629. % Commands to set those variables.
  630. % For example, this is what  @headings on  does
  631. % @evenheading @thistitle|@thispage|@thischapter
  632. % @oddheading @thischapter|@thispage|@thistitle
  633. % @evenfooting @thisfile||
  634. % @oddfooting ||@thisfile
  635.  
  636. \def\evenheading{\parsearg\evenheadingxxx}
  637. \def\oddheading{\parsearg\oddheadingxxx}
  638. \def\everyheading{\parsearg\everyheadingxxx}
  639.  
  640. \def\evenfooting{\parsearg\evenfootingxxx}
  641. \def\oddfooting{\parsearg\oddfootingxxx}
  642. \def\everyfooting{\parsearg\everyfootingxxx}
  643.  
  644. {\catcode`\@=0 %
  645.  
  646. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  647. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  648. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  649.  
  650. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  651. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  652. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  653.  
  654. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  655. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  656. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  657. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  658.  
  659. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  660. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  661. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  662.  
  663. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  664. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  665. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  666.  
  667. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  668. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  669. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  670. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  671. %
  672. }% unbind the catcode of @.
  673.  
  674. % @headings double    turns headings on for double-sided printing.
  675. % @headings single    turns headings on for single-sided printing.
  676. % @headings off        turns them off.
  677. % @headings on        same as @headings double, retained for compatibility.
  678. % By default, they are off.
  679.  
  680. \def\headings #1 {\csname HEADINGS#1\endcsname}
  681.  
  682. \def\HEADINGSoff{
  683. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  684. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  685. \HEADINGSoff
  686. % When we turn headings on, set the page number to 1.
  687. % For double-sided printing, put current file name in lower left corner,
  688. % chapter name on inside top of right hand pages, document
  689. % title on inside top of left hand pages, and page numbers on outside top
  690. % edge of all pages.
  691. \def\HEADINGSdouble{
  692. %\pagealignmacro
  693. \global\pageno=1
  694. \global\evenfootline={\hfil}
  695. \global\oddfootline={\hfil}
  696. \global\evenheadline={\line{\folio\hfil\thistitle}}
  697. \global\oddheadline={\line{\thischapter\hfil\folio}}
  698. }
  699. % For single-sided printing, chapter title goes across top left of page,
  700. % page number on top right.
  701. \def\HEADINGSsingle{
  702. %\pagealignmacro
  703. \global\pageno=1
  704. \global\evenfootline={\hfil}
  705. \global\oddfootline={\hfil}
  706. \global\evenheadline={\line{\thischapter\hfil\folio}}
  707. \global\oddheadline={\line{\thischapter\hfil\folio}}
  708. }
  709. \def\HEADINGSon{\HEADINGSdouble}
  710.  
  711. % Subroutines used in generating headings
  712. % Produces Day Month Year style of output.
  713. \def\today{\number\day\space
  714. \ifcase\month\or
  715. January\or February\or March\or April\or May\or June\or
  716. July\or August\or September\or October\or November\or December\fi
  717. \space\number\year}
  718.  
  719. % Use this if you want the Month Day, Year style of output.
  720. %\def\today{\ifcase\month\or
  721. %January\or February\or March\or April\or May\or June\or
  722. %July\or August\or September\or October\or November\or December\fi
  723. %\space\number\day, \number\year}
  724.  
  725. % @settitle line...  specifies the title of the document, for headings
  726. % It generates no output of its own
  727.  
  728. \def\thistitle{No Title}
  729. \def\settitle{\parsearg\settitlezzz}
  730. \def\settitlezzz #1{\gdef\thistitle{#1}}
  731.  
  732. \message{tables,}
  733.  
  734. % @tabs -- simple alignment
  735.  
  736. % These don't work.  For one thing, \+ is defined as outer.
  737. % So these macros cannot even be defined.
  738.  
  739. %\def\tabs{\parsearg\tabszzz}
  740. %\def\tabszzz #1{\settabs\+#1\cr}
  741. %\def\tabline{\parsearg\tablinezzz}
  742. %\def\tablinezzz #1{\+#1\cr}
  743. %\def\&{&}
  744.  
  745. % Tables -- @table, @ftable, @item(x), @kitem(x), @xitem(x).
  746.  
  747. % default indentation of table text
  748. \newdimen\tableindent \tableindent=.8in
  749. % default indentation of @itemize and @enumerate text
  750. \newdimen\itemindent  \itemindent=.3in
  751. % margin between end of table item and start of table text.
  752. \newdimen\itemmargin  \itemmargin=.1in
  753.  
  754. % used internally for \itemindent minus \itemmargin
  755. \newdimen\itemmax
  756.  
  757. % Note @table and @ftable define @item, @itemx, etc., with these defs.
  758. % They also define \itemindex
  759. % to index the item name in whatever manner is desired (perhaps none).
  760.  
  761. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  762. \def\internalBitemx{\par \parsearg\itemzzz}
  763.  
  764. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  765. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  766.  
  767. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  768. \def\internalBkitemx{\par \parsearg\kitemzzz}
  769.  
  770. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}\itemzzz {#1}}
  771.  
  772. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}\itemzzz {#1}}
  773.  
  774. \def\itemzzz #1{\begingroup %
  775. \advance \hsize by -\rightskip %
  776. \advance \hsize by -\leftskip %
  777. \setbox0=\hbox{\itemfont{#1}}%
  778. \itemindex{#1}%
  779. \parskip=0in %
  780. \noindent %
  781. \ifdim \wd0>\itemmax %
  782. \vadjust{\penalty 10000}%
  783. \hbox to \hsize{\hskip -\tableindent\box0\hss}\ %
  784. \else %
  785. \hbox to 0pt{\hskip -\tableindent\box0\hss}%
  786. \fi %
  787. \endgroup %
  788. }
  789.  
  790. \def\item{\errmessage{@item while not in a table}}
  791. \def\itemx{\errmessage{@itemx while not in a table}}
  792. \def\kitem{\errmessage{@kitem while not in a table}}
  793. \def\kitemx{\errmessage{@kitemx while not in a table}}
  794. \def\xitem{\errmessage{@xitem while not in a table}}
  795. \def\xitemx{\errmessage{@xitemx while not in a table}}
  796.  
  797. %% Contains a kludge to get @end[description] to work
  798. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  799.  
  800. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  801. {\obeylines\obeyspaces%
  802. \gdef\tablex #1^^M{%
  803. \tabley\dontindex#1        \endtabley}}
  804.  
  805. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  806. {\obeylines\obeyspaces%
  807. \gdef\ftablex #1^^M{%
  808. \tabley\fnitemindex#1        \endtabley}}
  809.  
  810. \def\dontindex #1{}
  811. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  812.  
  813. {\obeyspaces %
  814. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  815. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  816.  
  817. \def\tablez #1#2#3#4#5#6{%
  818. \aboveenvbreak %
  819. \begingroup %
  820. \def\Edescription{\Etable}% Neccessary kludge.
  821. \let\itemindex=#1%
  822. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  823. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  824. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  825. \def\itemfont{#2}%
  826. \itemmax=\tableindent %
  827. \advance \itemmax by -\itemmargin %
  828. \advance \leftskip by \tableindent %
  829. \parindent = 0pt
  830. \parskip = \smallskipamount
  831. \ifdim \parskip=0pt \parskip=2pt \fi%
  832. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  833. \let\item = \internalBitem %
  834. \let\itemx = \internalBitemx %
  835. \let\kitem = \internalBkitem %
  836. \let\kitemx = \internalBkitemx %
  837. \let\xitem = \internalBxitem %
  838. \let\xitemx = \internalBxitemx %
  839. }
  840.  
  841. % This is the counter used by @enumerate, which is really @itemize
  842.  
  843. \newcount \itemno
  844.  
  845. \def\itemize{\parsearg\itemizezzz}
  846.  
  847. \def\itemizezzz #1{\itemizey {#1}{\Eitemize}}
  848.  
  849. \def\itemizey #1#2{%
  850. \aboveenvbreak %
  851. \begingroup %
  852. \itemno = 0 %
  853. \itemmax=\itemindent %
  854. \advance \itemmax by -\itemmargin %
  855. \advance \leftskip by \itemindent %
  856. \parindent = 0pt
  857. \parskip = \smallskipamount
  858. \ifdim \parskip=0pt \parskip=2pt \fi%
  859. \def#2{\endgraf\endgroup\afterenvbreak}%
  860. \def\itemcontents{#1}%
  861. \let\item=\itemizeitem}
  862.  
  863. \def\bullet{$\ptexbullet$}
  864. \def\minus{$-$}
  865.  
  866. % Set sfcode to normal for the chars that usually have another value.
  867. % These are `.?!:;,'
  868. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  869.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  870.  
  871. \def\enumerate{\itemizey{\the\itemno.}\Eenumerate\flushcr}
  872.  
  873. % Definition of @item while inside @itemize.
  874.  
  875. \def\itemizeitem{%
  876. \advance\itemno by 1
  877. {\let\par=\endgraf \smallbreak}%
  878. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  879. {\parskip=0in \hskip 0pt
  880. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  881. \vadjust{\penalty 300}}%
  882. \flushcr}
  883.  
  884. \message{indexing,}
  885. % Index generation facilities
  886.  
  887. % Define \newwrite to be identical to plain tex's \newwrite
  888. % except not \outer, so it can be used within \newindex.
  889. {\catcode`\@=11
  890. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  891.  
  892. % \newindex {foo} defines an index named foo.
  893. % It automatically defines \fooindex such that
  894. % \fooindex ...rest of line... puts an entry in the index foo.
  895. % It also defines \fooindfile to be the number of the output channel for
  896. % the file that    accumulates this index.  The file's extension is foo.
  897. % The name of an index should be no more than 2 characters long
  898. % for the sake of vms.
  899.  
  900. \def\newindex #1{
  901. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  902. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  903. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  904. \noexpand\doindex {#1}}
  905. }
  906.  
  907. % @defindex foo  ==  \newindex{foo}
  908.  
  909. \def\defindex{\parsearg\newindex}
  910.  
  911. % Define @defcodeindex, like @defindex except put all entries in @code.
  912.  
  913. \def\newcodeindex #1{
  914. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  915. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  916. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  917. \noexpand\docodeindex {#1}}
  918. }
  919.  
  920. \def\defcodeindex{\parsearg\newcodeindex}
  921.  
  922. % @synindex foo bar    makes index foo feed into index bar.
  923. % Do this instead of @defindex foo if you don't want it as a separate index.
  924. \def\synindex #1 #2 {%
  925. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  926. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  927. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  928. \noexpand\doindex {#2}}%
  929. }
  930.  
  931. % @syncodeindex foo bar   similar, but put all entries made for index foo
  932. % inside @code.
  933. \def\syncodeindex #1 #2 {%
  934. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  935. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  936. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  937. \noexpand\docodeindex {#2}}%
  938. }
  939.  
  940. % Define \doindex, the driver for all \fooindex macros.
  941. % Argument #1 is generated by the calling \fooindex macro,
  942. %  and it is "foo", the name of the index.
  943.  
  944. % \doindex just uses \parsearg; it calls \doind for the actual work.
  945. % This is because \doind is more useful to call from other macros.
  946.  
  947. % There is also \dosubind {index}{topic}{subtopic}
  948. % which makes an entry in a two-level index such as the operation index.
  949.  
  950. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  951. \def\singleindexer #1{\doind{\indexname}{#1}}
  952.  
  953. % like the previous two, but they put @code around the argument.
  954. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  955. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  956.  
  957. \def\indexdummies{%
  958. \def\w{\realbackslash w }%
  959. \def\bf{\realbackslash bf }%
  960. \def\rm{\realbackslash rm }%
  961. \def\sl{\realbackslash sl }%
  962. \def\sf{\realbackslash sf}%
  963. \def\tt{\realbackslash tt}%
  964. \def\gtr{\realbackslash gtr}%
  965. \def\less{\realbackslash less}%
  966. \def\hat{\realbackslash hat}%
  967. \def\char{\realbackslash char}%
  968. \def\TeX{\realbackslash TeX}%
  969. \def\dots{\realbackslash dots }%
  970. \def\copyright{\realbackslash copyright }%
  971. \def\tclose##1{\realbackslash tclose {##1}}%
  972. \def\code##1{\realbackslash code {##1}}%
  973. \def\samp##1{\realbackslash samp {##1}}%
  974. \def\r##1{\realbackslash r {##1}}%
  975. \def\i##1{\realbackslash i {##1}}%
  976. \def\b##1{\realbackslash b {##1}}%
  977. \def\cite##1{\realbackslash cite {##1}}%
  978. \def\key##1{\realbackslash key {##1}}%
  979. \def\file##1{\realbackslash file {##1}}%
  980. \def\var##1{\realbackslash var {##1}}%
  981. \def\kbd##1{\realbackslash kbd {##1}}%
  982. }
  983.  
  984. % \indexnofonts no-ops all font-change commands.
  985. % This is used when outputting the strings to sort the index by.
  986. \def\indexdummyfont#1{#1}
  987. \def\indexnofonts{%
  988. \let\w=\indexdummyfont
  989. \let\r=\indexdummyfont
  990. \let\i=\indexdummyfont
  991. \let\b=\indexdummyfont
  992. \let\emph=\indexdummyfont
  993. \let\strong=\indexdummyfont
  994. \let\cite=\indexdummyfont
  995. \let\sc=\indexdummyfont
  996. %Don't no-op \tt, since it isn't a user-level command
  997. % and is used in the definitions of the actuve chars like <, >, |...
  998. %\let\tt=\indexdummyfont
  999. \let\tclose=\indexdummyfont
  1000. \let\code=\indexdummyfont
  1001. \let\file=\indexdummyfont
  1002. \let\samp=\indexdummyfont
  1003. \let\kbd=\indexdummyfont
  1004. \let\key=\indexdummyfont
  1005. \let\var=\indexdummyfont
  1006. }
  1007.  
  1008. % To define \realbackslash, we must make \ not be an escape.
  1009. % We must first make another character (@) an escape
  1010. % so we do not become unable to do a definition.
  1011.  
  1012. {\catcode`\@=0 \catcode`\\=\other
  1013. @gdef@realbackslash{\}}
  1014.  
  1015. \let\indexbackslash=0  %overridden during \printindex.
  1016.  
  1017. \def\doind #1#2{%
  1018. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1019. \count10=\lastpenalty %
  1020. \escapechar=`\\%
  1021. {\let\folio=0% Expand all macros now EXCEPT \folio
  1022. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1023. % so it will be output as is; and it will print as backslash in the indx.
  1024. %
  1025. % Now process the index-string once, with all font commands turned off,
  1026. % to get the string to sort the index by.
  1027. {\indexnofonts
  1028. \xdef\temp1{#2}%
  1029. }%
  1030. % Now produce the complete index entry.  We process the index-string again,
  1031. % this time with font commands expanded, to get what to print in the index.
  1032. \edef\temp{%
  1033. \write \csname#1indfile\endcsname{%
  1034. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1035. \temp }%
  1036. \penalty\count10}}
  1037.  
  1038. \def\dosubind #1#2#3{%
  1039. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1040. \count10=\lastpenalty %
  1041. \escapechar=`\\%
  1042. {\let\folio=0%
  1043. \def\rawbackslashxx{\indexbackslash}%
  1044. %
  1045. % Now process the index-string once, with all font commands turned off,
  1046. % to get the string to sort the index by.
  1047. {\indexnofonts
  1048. \xdef\temp1{#2 #3}%
  1049. }%
  1050. % Now produce the complete index entry.  We process the index-string again,
  1051. % this time with font commands expanded, to get what to print in the index.
  1052. \edef\temp{%
  1053. \write \csname#1indfile\endcsname{%
  1054. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1055. \temp }%
  1056. \penalty\count10}}
  1057.  
  1058. % The index entry written in the file actually looks like
  1059. %  \entry {sortstring}{page}{topic}
  1060. % or
  1061. %  \entry {sortstring}{page}{topic}{subtopic}
  1062. % The texindex program reads in these files and writes files
  1063. % containing these kinds of lines:
  1064. %  \initial {c}
  1065. %     before the first topic whose initial is c
  1066. %  \entry {topic}{pagelist}
  1067. %     for a topic that is used without subtopics
  1068. %  \primary {topic}
  1069. %     for the beginning of a topic that is used with subtopics
  1070. %  \secondary {subtopic}{pagelist}
  1071. %     for each subtopic.
  1072.  
  1073. % Define the user-accessible indexing commands 
  1074. % @findex, @vindex, @kindex, @cindex.
  1075.  
  1076. \def\findex {\fnindex}
  1077. \def\kindex {\kyindex}
  1078. \def\cindex {\cpindex}
  1079. \def\vindex {\vrindex}
  1080. \def\tindex {\tpindex}
  1081. \def\pindex {\pgindex}
  1082.  
  1083. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1084. {\obeylines %
  1085. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1086. \dosubind{cp}{#2}{#1}}}
  1087.  
  1088. % Define the macros used in formatting output of the sorted index material.
  1089.  
  1090. % This is what you call to cause a particular index to get printed.
  1091. % Write
  1092. % @unnumbered Function Index
  1093. % @printindex fn
  1094.  
  1095. \def\printindex{\parsearg\doprintindex}
  1096.  
  1097. \def\doprintindex#1{\tex %
  1098. \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1099. \catcode`\$=\other\catcode`\_=\other
  1100. \catcode`\~=\other
  1101. % The following don't help, since the chars were translated
  1102. % when the raw index was written, and their fonts were discarded
  1103. % due to \indexnofonts.
  1104. %\catcode`\"=\active
  1105. %\catcode`\^=\active
  1106. %\catcode`\_=\active
  1107. %\catcode`\|=\active
  1108. %\catcode`\<=\active
  1109. %\catcode`\>=\active
  1110. \def\indexbackslash{\rawbackslashxx}
  1111. \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1112. \begindoublecolumns
  1113. \openin 1 \jobname.#1s
  1114. \ifeof 1 \else \closein 1 \input \jobname.#1s
  1115. \fi
  1116. \enddoublecolumns
  1117. \Etex}
  1118.  
  1119. % These macros are used by the sorted index file itself.
  1120. % Change them to control the appearance of the index.
  1121.  
  1122. % Same as \bigskipamount except no shrink.
  1123. % \balancecolumns gets confused if there is any shrink.
  1124. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1125.  
  1126. \outer\def\initial #1{%
  1127. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1128. \ifdim\lastskip<\initialskipamount
  1129. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1130. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1131.  
  1132. \outer\def\entry #1#2{
  1133. {\parfillskip=0in \parskip=0in \parindent=0in
  1134. \hangindent=1in \hangafter=1%
  1135. \noindent\hbox{#1}\dotfill #2\par
  1136. }}
  1137.  
  1138. \def\primary #1{\line{#1\hfil}}
  1139.  
  1140. \newskip\secondaryindent \secondaryindent=0.5cm
  1141.  
  1142. \def\secondary #1#2{
  1143. {\parfillskip=0in \parskip=0in
  1144. \hangindent =1in \hangafter=1
  1145. \noindent\hskip\secondaryindent\hbox{#1}\dotfill #2\par
  1146. }}
  1147.  
  1148. %% Define two-column mode, which is used in indexes.
  1149. %% Adapted from the TeXBook, page 416
  1150. \catcode `\@=11
  1151.  
  1152. \newbox\partialpage
  1153.  
  1154. \newdimen\doublecolumnhsize  \doublecolumnhsize = 3.11in
  1155. \newdimen\doublecolumnvsize  \doublecolumnvsize = 19.1in
  1156. \newdimen\availdimen@
  1157.  
  1158. \def\begindoublecolumns{\begingroup
  1159.   \output={\global\setbox\partialpage=\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
  1160.   \output={\doublecolumnout} \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
  1161. \def\enddoublecolumns{\output={\balancecolumns}\eject
  1162.   \endgroup \pagegoal=\vsize}
  1163.  
  1164. \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1165.   \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1166.   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1167.   \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
  1168. \def\pagesofar{\unvbox\partialpage %
  1169.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1170. %          changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
  1171.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1172. \def\balancecolumns{%
  1173. % Unset the glue.
  1174.   \setbox255=\vbox{\unvbox255}
  1175.   \dimen@=\ht255
  1176.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1177.   \divide\dimen@ by2
  1178.   \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
  1179. % If the remaining data is too big for one page,
  1180. % output one page normally, then work with what remains.
  1181.   \ifdim \dimen@>\availdimen@
  1182.    {
  1183.      \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1184.      \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1185.      \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1186.      \onepageout\pagesofar
  1187.    }
  1188. % Recompute size of what remains, in case we just output some of it.
  1189.   \dimen@=\ht255
  1190.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1191.   \divide\dimen@ by2
  1192.   \fi
  1193.   \setbox0=\vbox{\unvbox255}
  1194.   \splittopskip=\topskip
  1195.   {\vbadness=10000 \loop \global\setbox3=\copy0
  1196.     \global\setbox1=\vsplit3 to\dimen@
  1197.     \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
  1198.   \setbox0=\vbox to\dimen@{\unvbox1}  \setbox2=\vbox to\dimen@{\unvbox3}
  1199.   \pagesofar}
  1200.  
  1201. \catcode `\@=\other
  1202. \message{sectioning,}
  1203. % Define chapters, sections, etc.
  1204.  
  1205. \newcount \chapno
  1206. \newcount \secno
  1207. \newcount \subsecno
  1208. \newcount \subsubsecno
  1209.  
  1210. % This counter is funny since it counts through charcodes of letters A, B, ...
  1211. \newcount \appendixno  \appendixno = `\@
  1212. \def\appendixletter{\char\the\appendixno}
  1213.  
  1214. \newwrite \contentsfile
  1215. % This is called from \setfilename.
  1216. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1217.  
  1218. % Each @chapter defines this as the name of the chapter.
  1219. % page headings and footings can use it.  @section does likewise
  1220.  
  1221. \def\thischapter{} \def\thissection{}
  1222. \def\seccheck#1{\if \pageno<0 %
  1223. \errmessage{@#1 not allowed after generating table of contents}\fi
  1224. %
  1225. }
  1226.  
  1227. \def\chapternofonts{%
  1228. \let\rawbackslash=\relax%
  1229. \let\frenchspacing=\relax%
  1230. \def\TeX{\realbackslash TeX}
  1231. \def\dots{\realbackslash dots}
  1232. \def\copyright{\realbackslash copyright}
  1233. \def\tt{\realbackslash tt}
  1234. \def\bf{\realbackslash bf }
  1235. \def\w{\realbackslash w}
  1236. \def\less{\realbackslash less}
  1237. \def\gtr{\realbackslash gtr}
  1238. \def\hat{\realbackslash hat}
  1239. \def\char{\realbackslash char}
  1240. \def\tclose##1{\realbackslash tclose {##1}}
  1241. \def\code##1{\realbackslash code {##1}}
  1242. \def\samp##1{\realbackslash samp {##1}}
  1243. \def\r##1{\realbackslash r {##1}}
  1244. \def\b##1{\realbackslash b {##1}}
  1245. \def\key##1{\realbackslash key {##1}}
  1246. \def\file##1{\realbackslash file {##1}}
  1247. \def\kbd##1{\realbackslash kbd {##1}}
  1248. % These are redefined because @smartitalic wouldn't work inside xdef.
  1249. \def\i##1{\realbackslash i {##1}}
  1250. \def\cite##1{\realbackslash cite {##1}}
  1251. \def\var##1{\realbackslash var {##1}}
  1252. \def\emph##1{\realbackslash emph {##1}}
  1253. \def\dfn##1{\realbackslash dfn {##1}}
  1254. }
  1255.  
  1256. \outer\def\chapter{\parsearg\chapterzzz}
  1257. \def\chapterzzz #1{\seccheck{chapter}%
  1258. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1259. \chapmacro {#1}{\the\chapno}%
  1260. \gdef\thissection{#1}%
  1261. \gdef\thischaptername{#1}%
  1262. % We don't substitute the actual chapter name into \thischapter
  1263. % because we don't want its macros evaluated now.
  1264. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1265. {\chapternofonts%
  1266. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1267. \escapechar=`\\%
  1268. \write \contentsfile \temp  %
  1269. \donoderef %
  1270. }}
  1271.  
  1272. \outer\def\appendix{\parsearg\appendixzzz}
  1273. \def\appendixzzz #1{\seccheck{appendix}%
  1274. \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1275. \chapmacro {#1}{Appendix \appendixletter}%
  1276. \gdef\thissection{#1}%
  1277. \gdef\thischaptername{#1}%
  1278. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  1279. {\chapternofonts%
  1280. \edef\temp{{\realbackslash chapentry {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1281. \escapechar=`\\%
  1282. \write \contentsfile \temp  %
  1283. \appendixnoderef %
  1284. }}
  1285.  
  1286. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1287. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1288. \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
  1289. \unnumbchapmacro {#1}%
  1290. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1291. {\chapternofonts%
  1292. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1293. \escapechar=`\\%
  1294. \write \contentsfile \temp  %
  1295. \unnumbnoderef %
  1296. }}
  1297.  
  1298. \outer\def\section{\parsearg\sectionzzz}
  1299. \def\sectionzzz #1{\seccheck{section}%
  1300. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1301. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1302. {\chapternofonts%
  1303. \edef\temp{{\realbackslash secentry %
  1304. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1305. \escapechar=`\\%
  1306. \write \contentsfile \temp %
  1307. \donoderef %
  1308. \penalty 10000 %
  1309. }}
  1310.  
  1311. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1312. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1313. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1314. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1315. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1316. {\chapternofonts%
  1317. \edef\temp{{\realbackslash secentry %
  1318. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1319. \escapechar=`\\%
  1320. \write \contentsfile \temp %
  1321. \appendixnoderef %
  1322. \penalty 10000 %
  1323. }}
  1324.  
  1325. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1326. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1327. \plainsecheading {#1}\gdef\thissection{#1}%
  1328. {\chapternofonts%
  1329. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1330. \escapechar=`\\%
  1331. \write \contentsfile \temp %
  1332. \unnumbnoderef %
  1333. \penalty 10000 %
  1334. }}
  1335.  
  1336. \outer\def\subsection{\parsearg\subsectionzzz}
  1337. \def\subsectionzzz #1{\seccheck{subsection}%
  1338. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1339. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1340. {\chapternofonts%
  1341. \edef\temp{{\realbackslash subsecentry %
  1342. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1343. \escapechar=`\\%
  1344. \write \contentsfile \temp %
  1345. \donoderef %
  1346. \penalty 10000 %
  1347. }}
  1348.  
  1349. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1350. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1351. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1352. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1353. {\chapternofonts%
  1354. \edef\temp{{\realbackslash subsecentry %
  1355. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1356. \escapechar=`\\%
  1357. \write \contentsfile \temp %
  1358. \appendixnoderef %
  1359. \penalty 10000 %
  1360. }}
  1361.  
  1362. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1363. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1364. \plainsecheading {#1}\gdef\thissection{#1}%
  1365. {\chapternofonts%
  1366. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1367. \escapechar=`\\%
  1368. \write \contentsfile \temp %
  1369. \unnumbnoderef %
  1370. \penalty 10000 %
  1371. }}
  1372.  
  1373. \outer\def\subsubsection{\parsearg\subsubsectionzzz}
  1374. \def\subsubsectionzzz #1{\seccheck{subsubsection}%
  1375. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1376. \subsubsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1377. {\chapternofonts%
  1378. \edef\temp{{\realbackslash subsubsecentry %
  1379. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1380. \escapechar=`\\%
  1381. \write \contentsfile \temp %
  1382. \donoderef %
  1383. \penalty 10000 %
  1384. }}
  1385.  
  1386. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1387. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1388. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1389. \subsubsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1390. {\chapternofonts%
  1391. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1392. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%\
  1393. \escapechar=`\\%
  1394. \write \contentsfile \temp %
  1395. \appendixnoderef %
  1396. \penalty 10000 %
  1397. }}
  1398.  
  1399. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1400. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1401. \plainsecheading {#1}\gdef\thissection{#1}%
  1402. {\chapternofonts%
  1403. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1404. \escapechar=`\\%
  1405. \write \contentsfile \temp %
  1406. \unnumbnoderef %
  1407. \penalty 10000 %
  1408. }}
  1409.  
  1410. % These are variants which are not "outer", so they can appear in @ifinfo.
  1411. \def\infounnumbered{\parsearg\unnumberedzzz}
  1412. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1413. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1414. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1415.  
  1416. \def\infoappendix{\parsearg\appendixzzz}
  1417. \def\infoappendixsec{\parsearg\appendixseczzz}
  1418. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1419. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1420.  
  1421. \def\infochapter{\parsearg\chapterzzz}
  1422. \def\infosection{\parsearg\sectionzzz}
  1423. \def\infosubsection{\parsearg\subsectionzzz}
  1424. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1425.  
  1426. % Define @majorheading, @heading and @subheading
  1427.  
  1428. \def\majorheading #1{%
  1429. {\advance\chapheadingskip by 10pt \chapbreak }%
  1430. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1431.  
  1432. \def\chapheading #1{\chapbreak %
  1433. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 200}
  1434.  
  1435. \def\heading{\parsearg\secheadingi}
  1436.  
  1437. % These macros generate a chapter, section, etc. heading only
  1438. % (including whitespace, linebreaking, etc. around it),
  1439. % given all the information in convenient, parsed form.
  1440.  
  1441. %%% Args are the skip and penalty (usually negative)
  1442. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1443.  
  1444. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1445.  
  1446. %%% Define plain chapter starts, and page on/off switching for it
  1447. % Parameter controlling skip before chapter headings (if needed)
  1448.  
  1449. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1450.  
  1451. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1452. \def\chappager{\par\vfill\supereject}
  1453. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1454.  
  1455. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1456.  
  1457. \def\CHAPPAGoff{
  1458. \global\let\pchapsepmacro=\chapbreak
  1459. \global\let\pagealignmacro=\chappager}
  1460.  
  1461. \def\CHAPPAGon{
  1462. \global\let\pchapsepmacro=\chappager
  1463. \global\let\pagealignmacro=\chappager
  1464. \global\def\HEADINGSon{\HEADINGSsingle}}
  1465.  
  1466. \def\CHAPPAGodd{
  1467. \global\let\pchapsepmacro=\chapoddpage
  1468. \global\let\pagealignmacro=\chapoddpage
  1469. \global\def\HEADINGSon{\HEADINGSdouble}}
  1470.  
  1471. \CHAPPAGon
  1472.  
  1473. \def\CHAPFplain{
  1474. \global\let\chapmacro=\chfplain
  1475. \global\let\unnumbchapmacro=\unnchfplain}
  1476.  
  1477. \def\chfplain #1#2{%
  1478. \pchapsepmacro %
  1479. {\chapfonts \line{\rm #2.\enspace #1\hfill}}\bigskip \par\penalty 5000 %
  1480. }
  1481.  
  1482. \def\unnchfplain #1{%
  1483. \pchapsepmacro %
  1484. {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1485. }
  1486. \CHAPFplain % The default
  1487.  
  1488. \def\unnchfopen #1{%
  1489. \chapoddpage {\chapfonts \line{\rm #1\hfill}}\bigskip \par\penalty 10000 %
  1490. }
  1491.  
  1492. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1493. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1494. \par\penalty 5000 %
  1495. }
  1496.  
  1497. \def\CHAPFopen{
  1498. \global\let\chapmacro=\chfopen
  1499. \global\let\unnumbchapmacro=\unnchfopen}
  1500.  
  1501. % Parameter controlling skip before section headings.
  1502.  
  1503. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1504. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1505.  
  1506. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1507. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1508.  
  1509.  
  1510. % Section fonts are the base font at magstep2, which produces
  1511. % a size a bit more than 14 points in the default situation.    
  1512.  
  1513. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  1514. \def\plainsecheading #1{\secheadingi {#1}}
  1515. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  1516. \secheadingbreak}%
  1517. {\secfonts \line{\rm #1\hfill}}%
  1518. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1519.  
  1520.  
  1521. % Subsection fonts are the base font at magstep1, 
  1522. % which produces a size of 12 points.
  1523.  
  1524. \def\subsecheading #1#2#3#4{{\advance \subsecheadingskip by \parskip %
  1525. \subsecheadingbreak}%
  1526. {\subsecfonts \line{\rm#2.#3.#4\enspace #1\hfill}}%
  1527. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  1528.  
  1529. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  1530.                   % Perhaps make sssec fonts scaled
  1531.                   % magstep half
  1532. \def\subsubsecheading #1#2#3#4#5{{\advance \subsecheadingskip by \parskip %
  1533. \subsecheadingbreak}%
  1534. {\subsubsecfonts \line{\rm#2.#3.#4.#5\enspace #1\hfill}}%
  1535. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  1536.  
  1537.  
  1538. \message{toc printing,}
  1539.  
  1540. % Finish up the main text and prepare to read what we've written
  1541. % to \contentsfile.
  1542.  
  1543. \def\startcontents#1{%
  1544.    \ifnum \pageno>0
  1545.       \pagealignmacro
  1546.       \immediate\closeout \contentsfile
  1547.       \pageno = -1        % Request roman numbered pages.
  1548.    \fi
  1549.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  1550.    % It is abundantly clear what they are.
  1551.    \unnumbchapmacro{#1}\def\thischapter{}%
  1552.    \begingroup           % Set up to handle contents files properly.
  1553.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  1554.       \raggedbottom             % Worry more about breakpoints than the bottom.
  1555.       \advance\hsize by -1in    % Don't use the full line length.
  1556. }
  1557.  
  1558.   
  1559. % Normal (long) toc.
  1560. \outer\def\contents{%
  1561.    \startcontents{Table of Contents}%
  1562.       \input \jobname.toc
  1563.    \endgroup
  1564.    \vfill \eject
  1565. }
  1566.  
  1567. % And just the chapters.
  1568. \outer\def\summarycontents{%
  1569.    \startcontents{Short Contents}%
  1570.       %
  1571.       \let\chapentry = \shortchapentry
  1572.       \let\unnumbchapentry = \shortunnumberedentry
  1573.       % We want a true roman here for the page numbers.
  1574.       \secfonts \let\rm = \truesecrm \rm
  1575.       \advance\baselineskip by 1pt % Open it up a little.
  1576.       \def\secentry ##1##2##3##4{}
  1577.       \def\unnumbsecentry ##1##2{}
  1578.       \def\subsecentry ##1##2##3##4##5{}
  1579.       \def\unnumbsubsecentry ##1##2{}
  1580.       \def\subsubsecentry ##1##2##3##4##5##6{}
  1581.       \def\unnumbsubsubsecentry ##1##2{}
  1582.       \input \jobname.toc
  1583.    \endgroup
  1584.    \vfill \eject
  1585. }
  1586. \let\shortcontents = \summarycontents
  1587.  
  1588. % These macros generate individual entries in the table of contents.
  1589. % The first argument is the chapter or section name.
  1590. % The last argument is the page number.
  1591. % The arguments in between are the chapter number, section number, ...
  1592.  
  1593. % Chapter-level things, for both the long and short contents.
  1594. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  1595. \def\shortchapentry#1#2#3{%
  1596.    \line{{#2\labelspace #1}\dotfill\doshortpageno{#3}}%
  1597. }
  1598.  
  1599. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  1600. \def\shortunnumberedentry#1#2{%
  1601.    \line{#1\dotfill\doshortpageno{#2}}%
  1602. }
  1603.  
  1604. % Sections.
  1605. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  1606. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  1607.  
  1608. % Subsections.
  1609. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  1610. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  1611.  
  1612. % And subsubsections.
  1613. \def\subsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  1614. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  1615.  
  1616.  
  1617. % This parameter controls the indentation of the various levels.
  1618. \newdimen\tocindent \tocindent = 3pc
  1619.  
  1620. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  1621. % page number.
  1622. %
  1623. % If the toc has to be broken over pages, we would want to be at chapters 
  1624. % if at all possible; hence the \penalty.
  1625. \def\dochapentry#1#2{%
  1626.    \penalty-300 \vskip\baselineskip
  1627.    \line{\chapentryfonts #1\dotfill \dopageno{#2}}%
  1628.    \nobreak\vskip .25\baselineskip
  1629. }
  1630.  
  1631. \def\dosecentry#1#2{%
  1632.    \line{\secentryfonts \hskip\tocindent #1\dotfill \dopageno{#2}}%
  1633. }
  1634.  
  1635. \def\dosubsecentry#1#2{%
  1636.    \line{\subsecentryfonts \hskip2\tocindent #1\dotfill \dopageno{#2}}%
  1637. }
  1638.  
  1639. \def\dosubsubsecentry#1#2{%
  1640.    \line{\subsubsecentryfonts \hskip3\tocindent #1\dotfill \dopageno{#2}}%
  1641. }
  1642.  
  1643. % Space between chapter (or whatever) number and the title.
  1644. \def\labelspace{\hskip1em \relax}
  1645.  
  1646. \def\dopageno#1{{\rm #1}}
  1647. \def\doshortpageno#1{{\rm #1}}
  1648.  
  1649. \def\chapentryfonts{\secfonts \rm}
  1650. \def\secentryfonts{\textfonts}
  1651. \let\subsecentryfonts = \textfonts
  1652. \let\subsubsecentryfonts = \textfonts
  1653.  
  1654.  
  1655. \message{environments,}
  1656.  
  1657. % Since these characters are used in examples, it should be an even number of 
  1658. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  1659. % Furthermore, these definitions must come after we define our fonts.
  1660. \newbox\dblarrowbox    \newbox\longdblarrowbox
  1661. \newbox\pushcharbox    \newbox\bullbox
  1662. \newbox\equivbox       \newbox\errorbox
  1663.  
  1664. \let\ptexequiv = \equiv
  1665.  
  1666. {\tentt
  1667. \global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  1668. \global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  1669. \global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  1670. \global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  1671. % Adapted from the manmac format (p.420 of TeXbook)
  1672. \global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  1673.                                       depth .1ex\hfil}
  1674. }
  1675.  
  1676. \def\point{$\star$}
  1677.  
  1678. \def\result{\leavevmode\raise.15ex\copy\dblarrowbox}
  1679. \def\expansion{\leavevmode\raise.1ex\copy\longdblarrowbox}
  1680. \def\print{\leavevmode\lower.1ex\copy\pushcharbox}
  1681.  
  1682. \def\equiv{\leavevmode\lower.1ex\copy\equivbox}
  1683.  
  1684. % Does anyone really want this?
  1685. % \def\bull{\leavevmode\copy\bullbox}
  1686.  
  1687. % Adapted from the TeXbook's \boxit.
  1688. {\tentt \global\dimen0 = 3em}% Width of the box.
  1689. \dimen2 = .55pt % Thickness of rules
  1690. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  1691. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  1692.  
  1693. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  1694.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  1695.    \advance\hsize by -2\dimen2 % Rules.
  1696.    \vbox{
  1697.       \hrule height\dimen2
  1698.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  1699.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  1700.          \kern3pt\vrule width\dimen2}% Space to right.
  1701.       \hrule height\dimen2}
  1702.     \hfil}
  1703.  
  1704. % The @error{} command.
  1705. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  1706.  
  1707. % @tex ... @end tex    escapes into raw Tex temporarily.
  1708. % One exception: @ is still an escape character, so that @end tex works.
  1709. % But \@ or @@ will get a plain tex @ character.
  1710.  
  1711. \def\tex{\begingroup
  1712. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  1713. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  1714. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  1715. \catcode `\%=14
  1716. \catcode`\"=12
  1717. \catcode`\==12
  1718. \catcode`\|=12
  1719. \catcode`\<=12
  1720. \catcode`\>=12
  1721. \escapechar=`\\
  1722. %
  1723. \let\{=\ptexlbrace
  1724. \let\}=\ptexrbrace
  1725. \let\.=\ptexdot
  1726. \let\*=\ptexstar
  1727. \def\@={@}%
  1728. \let\bullet=\ptexbullet
  1729. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  1730. \let\L=\ptexL
  1731. %
  1732. \let\Etex=\endgroup}
  1733.  
  1734. % Define @lisp ... @endlisp.
  1735. % @lisp does a \begingroup so it can rebind things,
  1736. % including the definition of @endlisp (which normally is erroneous).
  1737.  
  1738. % Amount to narrow the margins by for @lisp.
  1739. \newskip\lispnarrowing \lispnarrowing=0.4in
  1740.  
  1741. % This is the definition that ^M gets inside @lisp
  1742. % phr: changed space to \null, to avoid overfull hbox problems.
  1743. {\obeyspaces%
  1744. \gdef\lisppar{\null\endgraf}}
  1745.  
  1746. % Cause \obeyspaces to make each Space cause a word-separation
  1747. % rather than the default which is that it acts punctuation.
  1748. % This is because space in tt font looks funny.
  1749. {\obeyspaces %
  1750. \gdef\sepspaces{\def {\ }}}
  1751.  
  1752. \newskip\aboveenvskipamount \aboveenvskipamount= 0pt
  1753. \def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip
  1754. \endgraf \ifdim\lastskip<\aboveenvskipamount
  1755. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}}
  1756.  
  1757. \def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount
  1758. \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}
  1759.  
  1760. \def\lisp{\aboveenvbreak\begingroup\inENV %This group ends at the end of the @lisp body
  1761. \hfuzz=12truept % Don't be fussy
  1762. % Make spaces be word-separators rather than space tokens.
  1763. \sepspaces %
  1764. % Single space lines
  1765. \singlespace %
  1766. % The following causes blank lines not to be ignored
  1767. % by adding a space to the end of each line.
  1768. \let\par=\lisppar
  1769. \def\Elisp{\endgroup\afterenvbreak}%
  1770. \parskip=0pt
  1771. \advance \leftskip by \lispnarrowing
  1772. \parindent=0pt
  1773. \let\exdent=\internalexdent
  1774. \obeyspaces \obeylines \tt \rawbackslash
  1775. \def\next##1{}\next}
  1776.  
  1777.  
  1778. \let\example=\lisp
  1779. \def\Eexample{\Elisp}
  1780.  
  1781. \let\smallexample=\lisp
  1782. \def\Esmallexample{\Elisp}
  1783.  
  1784. % Macro for 9 pt. examples, necessary to print with 5" lines.
  1785. % From Pavel@xerox.  This is not really used unless the
  1786. % @smallbook command is given.
  1787.  
  1788. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  1789. %            This group ends at the end of the @lisp body
  1790. \hfuzz=12truept % Don't be fussy
  1791. % Make spaces be word-separators rather than space tokens.
  1792. \sepspaces %
  1793. % Single space lines
  1794. \singlespace %
  1795. % The following causes blank lines not to be ignored
  1796. % by adding a space to the end of each line.
  1797. \let\par=\lisppar
  1798. \def\Esmalllisp{\endgroup\afterenvbreak}%
  1799. \parskip=0pt
  1800. \advance \leftskip by \lispnarrowing
  1801. \parindent=0pt
  1802. \let\exdent=\internalexdent
  1803. \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
  1804. \def\next##1{}\next}
  1805.  
  1806. % This is @display; same as @lisp except use roman font.
  1807.  
  1808. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  1809. \aboveenvbreak
  1810. % Make spaces be word-separators rather than space tokens.
  1811. \sepspaces %
  1812. % Single space lines
  1813. \singlespace %
  1814. % The following causes blank lines not to be ignored
  1815. % by adding a space to the end of each line.
  1816. \let\par=\lisppar
  1817. \def\Edisplay{\endgroup\afterenvbreak}%
  1818. \parskip=0pt
  1819. \advance \leftskip by \lispnarrowing
  1820. \parindent=0pt
  1821. \let\exdent=\internalexdent
  1822. \obeyspaces \obeylines
  1823. \def\next##1{}\next}
  1824.  
  1825. % This is @format; same as @lisp except use roman font and don't narrow margins
  1826.  
  1827. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  1828. \aboveenvbreak
  1829. % Make spaces be word-separators rather than space tokens.
  1830. \sepspaces %
  1831. \singlespace %
  1832. % The following causes blank lines not to be ignored
  1833. % by adding a space to the end of each line.
  1834. \let\par=\lisppar
  1835. \def\Eformat{\endgroup\afterenvbreak}
  1836. \parskip=0pt \parindent=0pt
  1837. \obeyspaces \obeylines
  1838. \def\next##1{}\next}
  1839.  
  1840. % @flushleft and @flushright
  1841.  
  1842. \def\flushleft{\begingroup\inENV %This group ends at the end of the @format body
  1843. \aboveenvbreak
  1844. % Make spaces be word-separators rather than space tokens.
  1845. \sepspaces %
  1846. % The following causes blank lines not to be ignored
  1847. % by adding a space to the end of each line.
  1848. % This also causes @ to work when the directive name
  1849. % is terminated by end of line.
  1850. \let\par=\lisppar
  1851. \def\Eflushleft{\endgroup\afterenvbreak}%
  1852. \parskip=0pt \parindent=0pt
  1853. \obeyspaces \obeylines
  1854. \def\next##1{}\next}
  1855.  
  1856. \def\flushright{\begingroup\inENV %This group ends at the end of the @format body
  1857. \aboveenvbreak
  1858. % Make spaces be word-separators rather than space tokens.
  1859. \sepspaces %
  1860. % The following causes blank lines not to be ignored
  1861. % by adding a space to the end of each line.
  1862. % This also causes @ to work when the directive name
  1863. % is terminated by end of line.
  1864. \let\par=\lisppar
  1865. \def\Eflushright{\endgroup\afterenvbreak}%
  1866. \parskip=0pt \parindent=0pt
  1867. \advance \leftskip by 0pt plus 1fill
  1868. \obeyspaces \obeylines
  1869. \def\next##1{}\next}
  1870.  
  1871. % @quotation - narrow the margins.
  1872.  
  1873. \def\quotation{\begingroup\inENV %This group ends at the end of the @quotation body
  1874. {\parskip=0pt  % because we will skip by \parskip too, later
  1875. \aboveenvbreak}%
  1876. \singlespace
  1877. \parindent=0pt
  1878. \def\Equotation{\par\endgroup\afterenvbreak}%
  1879. \advance \rightskip by \lispnarrowing 
  1880. \advance \leftskip by \lispnarrowing}
  1881.  
  1882. \message{defuns,}
  1883. % Define formatter for defuns
  1884. % First, allow user to change definition object font (\df) internally
  1885. \def\setdeffont #1 {\csname DEF#1\endcsname}
  1886.  
  1887. \newskip\defbodyindent \defbodyindent=.4in
  1888. \newskip\defargsindent \defargsindent=50pt
  1889. \newskip\deftypemargin \deftypemargin=12pt
  1890. \newskip\deflastargmargin \deflastargmargin=18pt
  1891.  
  1892. \newcount\parencount
  1893. % define \functionparens, which makes ( and ) and & do special things.
  1894. % \functionparens affects the group it is contained in.
  1895. \def\activeparens{%
  1896. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  1897. \catcode`\[=\active \catcode`\]=\active}
  1898. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  1899. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  1900. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  1901.  
  1902. % Definitions of (, ) and & used in args for functions.
  1903. % This is the definition of ( outside of all parentheses.
  1904. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  1905. \global\advance\parencount by 1 }
  1906. %
  1907. % This is the definition of ( when already inside a level of parens.
  1908. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  1909. %
  1910. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  1911. % also in that case restore the outer-level definition of (.
  1912. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  1913. \global\advance \parencount by -1 }
  1914. % If we encounter &foo, then turn on ()-hacking afterwards
  1915. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  1916. %
  1917. \gdef\normalparens{\boldbrax\let&=\ampnr}
  1918. } % End of definition inside \activeparens
  1919. %% These parens (in \boldbrax) actually are a little bolder than the
  1920. %% contained text.  This is especially needed for [ and ]
  1921. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  1922. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  1923.  
  1924. % First, defname, which formats the header line itself.
  1925. % #1 should be the function name.
  1926. % #2 should be the type of definition, such as "Function".
  1927.  
  1928. \def\defname #1#2{%
  1929. \leftskip = 0in  %
  1930. \noindent        %
  1931. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  1932. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  1933. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  1934. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  1935. % Now output arg 2 ("Function" or some such)
  1936. % ending at \deftypemargin from the right margin,
  1937. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  1938. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}%
  1939. \tolerance=10000 \hbadness=10000    % Make all lines underfull and no complaints
  1940. {\df #1}\enskip        % Generate function name
  1941. }
  1942.  
  1943. % Actually process the body of a definition
  1944. % #1 should be the terminating control sequence, such as \Edefun.
  1945. % #2 should be the "another name" control sequence, such as \defunx.
  1946. % #3 should be the control sequence that actually processes the header,
  1947. %    such as \defunheader.
  1948.  
  1949. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  1950. \medbreak %
  1951. % Define the end token that this defining construct specifies
  1952. % so that it will exit this group.
  1953. \def#1{\endgraf\endgroup\medbreak}%
  1954. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  1955. \parindent=0in \leftskip=\defbodyindent \rightskip=\defbodyindent %
  1956. \begingroup %
  1957. \catcode 61=\active %
  1958. \obeylines\activeparens\spacesplit#3}
  1959.  
  1960. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  1961. \medbreak %
  1962. % Define the end token that this defining construct specifies
  1963. % so that it will exit this group.
  1964. \def#1{\endgraf\endgroup\medbreak}%
  1965. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  1966. \parindent=0in \leftskip=\defbodyindent \rightskip=\defbodyindent %
  1967. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  1968.  
  1969. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  1970. \medbreak %
  1971. % Define the end token that this defining construct specifies
  1972. % so that it will exit this group.
  1973. \def#1{\endgraf\endgroup\medbreak}%
  1974. \def#2##1 ##2 {\def#4{##1}%
  1975. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  1976. \parindent=0in \leftskip=\defbodyindent %
  1977. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  1978.  
  1979. % Split up #2 at the first space token.
  1980. % call #1 with two arguments:
  1981. %  the first is all of #2 before the space token,
  1982. %  the second is all of #2 after that space token.
  1983. % If #2 contains no space token, all of it is passed as the first arg
  1984. % and the second is passed as empty.
  1985.  
  1986. {\obeylines
  1987. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  1988. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  1989. \ifx\relax #3%
  1990. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  1991.  
  1992. % So much for the things common to all kinds of definitions.
  1993.  
  1994. % Define @defun.
  1995.  
  1996. % First, define the processing that is wanted for arguments of \defun
  1997. % Use this to expand the args and terminate the paragraph they make up
  1998.  
  1999. \def\defunargs #1{\functionparens \sl
  2000. % Expand, preventing hyphenation at `-' chars.
  2001. % Note that groups don't affect changes in \hyphenchar.
  2002. \hyphenchar\sl=0
  2003. #1%
  2004. \hyphenchar\sl=45
  2005. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  2006. \interlinepenalty=10000
  2007. \advance\rightskip by 0pt plus 1fil
  2008. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2009. }
  2010.  
  2011. % Do complete processing of one @defun or @defunx line already parsed.
  2012.  
  2013. % @deffn Command forward-char nchars
  2014.  
  2015. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2016.  
  2017. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2018. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2019. \catcode 61=\other % Turn off change made in \defparsebody
  2020. }
  2021.  
  2022. % @defun == @deffn Function
  2023.  
  2024. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2025.  
  2026. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2027. \begingroup\defname {#1}{Function}%
  2028. \defunargs {#2}\endgroup %
  2029. \catcode 61=\other % Turn off change made in \defparsebody
  2030. }
  2031.  
  2032. % @defmac == @deffn Macro
  2033.  
  2034. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2035.  
  2036. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2037. \begingroup\defname {#1}{Macro}%
  2038. \defunargs {#2}\endgroup %
  2039. \catcode 61=\other % Turn off change made in \defparsebody
  2040. }
  2041.  
  2042. % @defspec == @deffn Special Form
  2043.  
  2044. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2045.  
  2046. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2047. \begingroup\defname {#1}{Special Form}%
  2048. \defunargs {#2}\endgroup %
  2049. \catcode 61=\other % Turn off change made in \defparsebody
  2050. }
  2051.  
  2052. % This definition is run if you use @defunx
  2053. % anywhere other than immediately after a @defun or @defunx.
  2054.  
  2055. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2056. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2057. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2058. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2059.  
  2060. % @defmethod, and so on
  2061.  
  2062. % @defop {Funny Method} foo-class frobnicate argument
  2063.  
  2064. \def\defop #1 {\def\defoptype{#1}%
  2065. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2066.  
  2067. \def\defopheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2068. \begingroup\defname {#2}{\defoptype{} on #1}%
  2069. \defunargs {#3}\endgroup %
  2070. }
  2071.  
  2072. % @defmethod == @defop Method
  2073.  
  2074. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2075.  
  2076. \def\defmethodheader #1#2#3{\dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2077. \begingroup\defname {#2}{Operation on #1}%
  2078. \defunargs {#3}\endgroup %
  2079. }
  2080.  
  2081. % @defcv {Class Option} foo-class foo-flag
  2082.  
  2083. \def\defcv #1 {\def\defcvtype{#1}%
  2084. \defopparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2085.  
  2086. \def\defcvarheader #1#2#3{%
  2087. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2088. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2089. \defvarargs {#3}\endgroup %
  2090. }
  2091.  
  2092. % @defivar == @defcv {Instance Variable}
  2093.  
  2094. \def\defivar{\defmethparsebody\Edefivar\defivarx\defivarheader}
  2095.  
  2096. \def\defivarheader #1#2#3{%
  2097. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2098. \begingroup\defname {#2}{Instance variable of #1}%
  2099. \defvarargs {#3}\endgroup %
  2100. }
  2101.  
  2102. % These definitions are run if you use @defmethodx, etc.,
  2103. % anywhere other than immediately after a @defmethod, etc.
  2104.  
  2105. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2106. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2107. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2108. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2109.  
  2110. % Now @defvar
  2111.  
  2112. % First, define the processing that is wanted for arguments of @defvar.
  2113. % This is actually simple: just print them in roman.
  2114. % This must expand the args and terminate the paragraph they make up
  2115. \def\defvarargs #1{\normalparens #1%
  2116. \interlinepenalty=10000
  2117. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2118.  
  2119. % @defvr Counter foo-count
  2120.  
  2121. \def\defvr{\defmethparsebody\Edefvr\defvrx\defvrheader}
  2122.  
  2123. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2124. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2125.  
  2126. % @defvar == @defvr Variable
  2127.  
  2128. \def\defvar{\defparsebody\Edefvar\defvarx\defvarheader}
  2129.  
  2130. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2131. \begingroup\defname {#1}{Variable}%
  2132. \defvarargs {#2}\endgroup %
  2133. }
  2134.  
  2135. % @defopt == @defvr {User Option}
  2136.  
  2137. \def\defopt{\defparsebody\Edefopt\defoptx\defoptheader}
  2138.  
  2139. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2140. \begingroup\defname {#1}{User Option}%
  2141. \defvarargs {#2}\endgroup %
  2142. }
  2143.  
  2144. % This definition is run if you use @defvarx
  2145. % anywhere other than immediately after a @defvar or @defvarx.
  2146.  
  2147. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2148. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2149. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2150.  
  2151. % Now define @deftp
  2152. % Args are printed in bold, a slight difference from @defvar.
  2153.  
  2154. \def\deftpargs #1{\bf \defvarargs{#1}}
  2155.  
  2156. % @deftp Class window height width ...
  2157.  
  2158. \def\deftp{\defmethparsebody\Edeftp\deftpx\deftpheader}
  2159.  
  2160. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2161. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2162.  
  2163. % This definition is run if you use @deftpx, etc
  2164. % anywhere other than immediately after a @deftp, etc.
  2165.  
  2166. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2167.  
  2168. \message{cross reference,}
  2169. % Define cross-reference macros
  2170. \newwrite \auxfile
  2171.  
  2172. \newif\ifhavexrefs  % True if xref values are known.
  2173. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2174.  
  2175. % \setref{foo} defines a cross-reference point named foo.
  2176.  
  2177. \def\setref#1{%
  2178. \dosetq{#1-pg}{Ypagenumber}%
  2179. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2180.  
  2181. \def\unnumbsetref#1{%
  2182. \dosetq{#1-pg}{Ypagenumber}%
  2183. \dosetq{#1-snt}{Ynothing}}
  2184.  
  2185. \def\appendixsetref#1{%
  2186. \dosetq{#1-pg}{Ypagenumber}%
  2187. \dosetq{#1-snt}{Yappendixletterandtype}}
  2188.  
  2189. % \xref and \pxref generate cross references to specified points.
  2190.  
  2191. \def\pxref #1{see \xrefX [#1,,,,,,,]}
  2192. \def\xref #1{See \xrefX [#1,,,,,,,]}
  2193. \def\ref #1{\xrefX [#1,,,,,,,]}
  2194. \def\xrefX [#1,#2,#3,#4,#5,#6]{%
  2195. {\setbox1=\hbox{\i{\losespace#5{}}}%
  2196. \setbox0=\hbox{\losespace#3{}}%
  2197. \ifdim \wd0 =0pt \setbox0=\hbox{\losespace#1{}}\fi%
  2198. \ifdim \wd1 >0pt%
  2199. section `\unhbox0' in \unhbox1%
  2200. \else%
  2201. \turnoffactive%
  2202. \refx{#1-snt}{} [\unhbox0], page\tie \refx{#1-pg}{}%
  2203. \fi }}
  2204.  
  2205. % \dosetq is the interface for calls from other macros
  2206.  
  2207. % Use \turnoffactive so that punctuation chars such as underscore
  2208. % work in node names.
  2209. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  2210. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2211. \next}}
  2212.  
  2213. % \internalsetq {foo}{page} expands into CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2214. % When the aux file is read, ' is the escape character
  2215.  
  2216. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2217.  
  2218. % Things to be expanded by \internalsetq
  2219.  
  2220. \def\Ypagenumber{\folio}
  2221.  
  2222. \def\Ynothing{}
  2223.  
  2224. \def\Ysectionnumberandtype{%
  2225. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  2226. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  2227. \else \ifnum \subsubsecno=0 %
  2228. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  2229. \else %
  2230. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2231. \fi \fi \fi }
  2232.  
  2233. \def\Yappendixletterandtype{%
  2234. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno %
  2235. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  2236. \else \ifnum \subsubsecno=0 %
  2237. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2238. \else %
  2239. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2240. \fi \fi \fi }
  2241.  
  2242. \gdef\xreftie{'tie}
  2243.  
  2244. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2245. % If its value is nonempty, SUFFIX is output afterward.
  2246.  
  2247. \def\refx#1#2{%
  2248. {%
  2249. \expandafter\ifx\csname X#1\endcsname\relax
  2250. % If not defined, say something at least.
  2251. {$\langle$un\-def\-in\-ed$\rangle$}#2%
  2252. \ifhavexrefs
  2253. \message {WARNING: undefined cross-reference "#1"}%
  2254. \message {}%
  2255. \else
  2256. \ifwarnedxrefs
  2257. \else
  2258. \global\warnedxrefstrue
  2259. \message {WARNING: cross-references values are not known; you must run TeX a second time}%
  2260. \message {}%
  2261. \fi
  2262. \fi
  2263. \fi
  2264. \setbox0=\hbox{\csname X#1\endcsname}%It's defined, so just use it.
  2265. \ifdim\wd0>0pt \unhbox0{}#2\fi
  2266. }}
  2267.  
  2268. % Read the last existing aux file, if any.  No error if none exists.
  2269.  
  2270. % This is the macro invoked by entries in the aux file.
  2271. \def\xrdef #1#2{
  2272. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2273.  
  2274. \def\readauxfile{%
  2275. \begingroup
  2276. \catcode `\^^@=\other
  2277. \catcode `\=\other
  2278. \catcode `\=\other
  2279. \catcode `\^^C=\other
  2280. \catcode `\^^D=\other
  2281. \catcode `\^^E=\other
  2282. \catcode `\^^F=\other
  2283. \catcode `\^^G=\other
  2284. \catcode `\^^H=\other
  2285. \catcode `\ =\other
  2286. \catcode `\^^L=\other
  2287. \catcode `\=\other
  2288. \catcode `\=\other
  2289. \catcode `\=\other
  2290. \catcode `\=\other
  2291. \catcode `\=\other
  2292. \catcode `\=\other
  2293. \catcode `\=\other
  2294. \catcode `\=\other
  2295. \catcode `\=\other
  2296. \catcode `\=\other
  2297. \catcode `\=\other
  2298. \catcode `\=\other
  2299. \catcode `\=\other
  2300. \catcode `\^^[=\other
  2301. \catcode `\^^\=\other
  2302. \catcode `\^^]=\other
  2303. \catcode `\^^^=\other
  2304. \catcode `\^^_=\other
  2305. \catcode `\@=\other
  2306. \catcode `\^=\other
  2307. \catcode `\~=\other
  2308. \catcode `\[=\other
  2309. \catcode `\]=\other
  2310. \catcode`\"=\other
  2311. \catcode`\_=\other
  2312. \catcode`\|=\other
  2313. \catcode`\<=\other
  2314. \catcode`\>=\other
  2315. \catcode `\$=\other
  2316. \catcode `\#=\other
  2317. \catcode `\&=\other
  2318. % the aux file uses ' as the escape.
  2319. % Turn off \ as an escape so we do not lose on
  2320. % entries which were dumped with control sequences in their names.
  2321. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  2322. % Reference to such entries still does not work the way one would wish,
  2323. % but at least they do not bomb out when the aux file is read in.
  2324. \catcode `\{=1 \catcode `\}=2
  2325. \catcode `\%=\other
  2326. \catcode `\'=0
  2327. \catcode `\\=\other
  2328. \openin 1 \jobname.aux
  2329. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  2330. \fi
  2331. % Open the new aux file.  Tex will close it automatically at exit.
  2332. \openout \auxfile=\jobname.aux
  2333. \endgroup}
  2334.  
  2335.  
  2336. % Footnotes.
  2337.  
  2338. \newcount \footnoteno
  2339.  
  2340. \def\supereject{\par\penalty -20000\footnoteno =0 }
  2341.  
  2342. \let\ptexfootnote=\footnote
  2343.  
  2344. {\catcode `\@=11
  2345. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  2346. \edef\thisfootno{$^{\the\footnoteno}$}%
  2347. \let\@sf\empty
  2348. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  2349. \thisfootno\@sf \footnotezzz{#1}}
  2350. % \parsearg\footnotezzz}
  2351.  
  2352. \long\gdef\footnotezzz #1{\insert\footins{
  2353. \interlinepenalty\interfootnotelinepenalty
  2354. \splittopskip\ht\strutbox % top baseline for broken footnotes
  2355. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  2356. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  2357. \footstrut\hang\textindent{\thisfootno}#1\strut}}
  2358.  
  2359. }%end \catcode `\@=11
  2360.  
  2361. % End of control word definitions.
  2362.  
  2363. \message{and turning on texinfo input format.}
  2364.  
  2365. \def\openindices{%
  2366.    \newindex{cp}%
  2367.    \newcodeindex{fn}%
  2368.    \newcodeindex{vr}%
  2369.    \newcodeindex{tp}%
  2370.    \newcodeindex{ky}%
  2371.    \newcodeindex{pg}%
  2372. }
  2373.  
  2374. % Set some numeric style parameters, for 8.5 x 11 format.
  2375.  
  2376. %\hsize = 6.5in
  2377. \parindent 15pt
  2378. \parskip 18pt plus 1pt
  2379. \baselineskip 15pt
  2380. \advance\topskip by 1.2cm
  2381.  
  2382. % Prevent underfull vbox error messages.
  2383. \vbadness=10000
  2384.  
  2385. % Use @smallbook to reset parameters for 7x9.5 format
  2386. \def\smallbook{
  2387. \global\lispnarrowing = 0.3in
  2388. \global\baselineskip 12pt
  2389. \global\parskip 3pt plus 1pt
  2390. \global\hsize = 5in
  2391. \global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
  2392. \global\vsize=7.5in
  2393. \global\tolerance=700
  2394. \global\hfuzz=1pt
  2395.  
  2396. \global\pagewidth=\hsize
  2397. \global\pageheight=\vsize
  2398.  
  2399. \global\let\smalllisp=\smalllispx
  2400. \global\let\smallexample=\smalllispx
  2401. \global\def\Esmallexample{\Esmalllisp}
  2402. }
  2403.  
  2404. %% For a final copy, take out the rectangles
  2405. %% that mark overfull boxes (in case you have decided
  2406. %% that the text looks ok even though it passes the margin).
  2407. \def\finalout{\overfullrule=0pt}
  2408.  
  2409. % Define macros to output various characters with catcode for normal text.
  2410. \catcode`\"=\other
  2411. \catcode`\~=\other
  2412. \catcode`\^=\other
  2413. \catcode`\_=\other
  2414. \catcode`\|=\other
  2415. \catcode`\<=\other
  2416. \catcode`\>=\other
  2417. \catcode`\+=\other
  2418. \def\normaldoublequote{"}
  2419. \def\normaltilde{~}
  2420. \def\normalcaret{^}
  2421. \def\normalunderscore{_}
  2422. \def\normalverticalbar{|}
  2423. \def\normalless{<}
  2424. \def\normalgreater{>}
  2425. \def\normalplus{+}
  2426.  
  2427. % Turn off all special characters except @
  2428. % (and those which the user can use as if they were ordinary)
  2429. % Define certain chars to be always in tt font.
  2430.  
  2431. \catcode`\"=\active
  2432. \def\activedoublequote{{\tt \char '042}}
  2433. \let"=\activedoublequote
  2434. \catcode`\~=\active
  2435. \def~{{\tt \char '176}}
  2436. \chardef\hat=`\^
  2437. \catcode`\^=\active
  2438. \def^{{\tt \hat}}
  2439. \catcode`\_=\active
  2440. \def_{{\tt \char '137}}
  2441. \catcode`\|=\active
  2442. \def|{{\tt \char '174}}
  2443. \chardef \less=`\<
  2444. \catcode`\<=\active
  2445. \def<{{\tt \less}}
  2446. \chardef \gtr=`\>
  2447. \catcode`\>=\active
  2448. \def>{{\tt \gtr}}
  2449. \catcode`\+=\active
  2450. \def+{{\tt \char 43}}
  2451. %\catcode 27=\active
  2452. %\def^^[{$\diamondsuit$}
  2453.  
  2454. % Used sometimes to turn off (effectively) the active characters
  2455. % even after parsing them.
  2456. \def\turnoffactive{\let"=\normaldoublequote
  2457. \let~=\normaltilde
  2458. \let^=\normalcaret
  2459. \let_=\normalunderscore
  2460. \let|=\normalverticalbar
  2461. \let<=\normalless
  2462. \let>=\normalgreater
  2463. \let+=\normalplus}
  2464.  
  2465. % Set up an active definition for =, but don't enable it most of the time.
  2466. {\catcode`\==\active
  2467. \global\def={{\tt \char 61}}}
  2468.  
  2469. \catcode`\@=0
  2470.  
  2471. % \rawbackslashxx output one backslash character in current font
  2472. \global\chardef\rawbackslashxx=`\\
  2473. %{\catcode`\\=\other
  2474. %@gdef@rawbackslashxx{\}}
  2475.  
  2476. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  2477. {\catcode`\\=\active
  2478. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  2479.  
  2480. % \normalbackslash outputs one backslash in fixed width font.
  2481. \def\normalbackslash{{\tt\rawbackslashxx}}
  2482.  
  2483. % Say @foo, not \foo, in error messages.
  2484. \escapechar=`\@
  2485.  
  2486. @c \catcode 17=0   @c Define control-q
  2487. \catcode`\\=\active
  2488.  
  2489. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  2490. % That is what \eatinput is for; after that, the `\' should revert to printing 
  2491. % a backslash.
  2492. %
  2493. @gdef@eatinput input texinfo{@fixbackslash}
  2494. @global@let\ = @eatinput
  2495.  
  2496. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  2497. % the first `\{ in the file would cause an error. This macro tries to fix 
  2498. % that, assuming it is called before the first `\' could plausibly occur.
  2499. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  2500.  
  2501. %% These look ok in all fonts, so just make them not special.  The @rm below
  2502. %% makes sure that the current font starts out as the newly loaded cmr10
  2503. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  2504.  
  2505. @textfonts
  2506. @rm
  2507.